﻿namespace Erp
{
    public partial class View_系统设置 : UserControl
    {
        public View_系统设置()
        {
            InitializeComponent();

            初始化();
        }

        private void 初始化()
        {
            txt验货枪识别码.Text = ErpSettings.Default.验货枪识别码;
            txt发货枪识别码.Text = ErpSettings.Default.发货枪识别码;
        }
        private void btn退出系统设置_Click(object sender, EventArgs e)
        {
            this.Dispose();
            Controller.系统设置 = null;
        }



        private void btnCheckSave_Click(object sender, EventArgs e)
        {
            ErpSettings.Default.验货枪识别码 = txt验货枪识别码.Text.Trim();
            ErpSettings.Default.Save();

            Controller.验货枪识别码 = ErpSettings.Default.验货枪识别码;
        }

        private void btnSendSave_Click(object sender, EventArgs e)
        {
            ErpSettings.Default.发货枪识别码 = txt发货枪识别码.Text.Trim();
            ErpSettings.Default.Save();

            Controller.发货枪识别码 = ErpSettings.Default.发货枪识别码;
        }

        private void btnDefault_Click(object sender, EventArgs e)
        {
            ErpSettings.Default.Reset();
            ErpSettings.Default.Save();

            txt验货枪识别码.Text = ErpSettings.Default.验货枪识别码;
            Controller.验货枪识别码 = ErpSettings.Default.验货枪识别码;

            txt发货枪识别码.Text = ErpSettings.Default.发货枪识别码;
            Controller.发货枪识别码 = ErpSettings.Default.发货枪识别码;
        }

        private void chk识别验货枪_CheckedChanged(object sender, EventArgs e)
        {
            if (chk识别验货枪.Checked)
            {
                Controller.启动验货枪识别 = true;
            }
            else
            {
                Controller.启动验货枪识别 = false;
            }
        }

        private void chk识别发货枪_CheckedChanged(object sender, EventArgs e)
        {
            if (chk识别发货枪.Checked)
            {
                Controller.启动发货枪识别 = true;
            }
            else
            { 
                Controller.启动发货枪识别 = false;
            }
        }
    }
}
